var AV = require('leanengine');


var APP_ID = '64yipwcn159l9ehdf3j3x3xz1f1ly9r89x9gf7i2d1282dvz';
var APP_KEY = 'w3xp0oibbzhweamm76ogo6r5dyzt82tczw7lssfvyj6hlarv';
var MASTER_KEY = 'zlf6rkt286shvykgo08dht3938tg3ln2idvfcu7t61h1ngfq';

AV.initialize(APP_ID, APP_KEY, MASTER_KEY);
// 如果不希望使用 masterKey 权限，可以将下面一行删除
AV.Cloud.useMasterKey();
// TODO 说明文档更新
AV.Promise._isPromisesAPlusCompliant = false;



var Version = AV.Object.extend('Version');

//获取当前的版本信息
exports.getVersion = function (next) {
    //TODO:获取app当前的版本号
    var query = new AV.Query(Version);
    query.descending('createdAt');
    query.first().then(function(v){
        console.log(v);
        next(null, v.get('name'));
    });
}